import { onMounted, ref } from 'vue'
import { ToolType } from '@/types/tools.ts'

export default function () {
  // 获取工具列表
  let toolList = ref<Record<string, ToolType[]>>({})
  onMounted(async () => {
    const toolData = await fetch('/data/tools.json').then((r) => r.json())
    toolList.value = toolData.reduce((acc: any, tool: any) => {
      acc[tool.category] ||= []
      acc[tool.category].push(tool)
      return acc
    }, {})
  })
  return { toolList }
}
